Skip to content

Run find-flaky on CI when new E2E or X% diff - #8860

Open
nielsVoogt wants to merge 7 commits into
mainfrom
niels/investigation.flaky-test-hunter-on-pr
Open

nielsVoogt wants to merge 7 commits into
mainfrom
niels/investigation.flaky-test-hunter-on-pr

Conversation

@nielsVoogt

@nielsVoogt nielsVoogt commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

AB#44653

Describe your changes

This adds a job that runs find-flaky (30x) when someone edits (--threshold: 10%), or adds a new E2E test.
Hopefully this will stop flaky tests from entering our codebase

Checklist before requesting a code review

  • I have performed a self-review of my code
  • I have addressed all Copilot comments
  • The changes do not touch the UI/UX
  • Adding tests is irrelevant for this PR
  • I have made sure that all automated checks pass before requesting a review
  • I do not need any deviation from our PR guidelines

Portal preview-deployment

This PR does not have any preview deployments yet.

Copilot AI lite review requested due to automatic review settings September 17, 2026 07:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical workflow and validation-fixture issues prevent reliable flaky-test detection.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds PR-based flaky-test detection for changed or new Portal E2E specs.

Changes:

  • Adds changed-spec selection tooling and an npm command.
  • Integrates candidate detection and repeated flaky-test runs into CI.
  • Adds temporary stable and flaky validation specs.
File summaries
File Description
tools/select-changed-e2e-tests.mjs Selects qualifying changed E2E specs.
tools/package.json Registers the selector command.
e2e/portal/tests/TestingCi/PurposlyStable.spec.ts Adds stable CI validation coverage.
e2e/portal/tests/TestingCi/PurposelyFlaky.spec.ts Adds temporary flaky-test validation.
.github/workflows/test_e2e_portal.yml Runs candidate detection and flaky-test jobs.
Review details

Suppressed comments (1)

.github/workflows/test_e2e_portal.yml:92

  • This new job is gated by path-filter, but that filter does not include tools/select-changed-e2e-tests.mjs. After this PR, a future change to the selector alone will make the E2E workflow skip candidate detection, so regressions in this CI-critical script can merge without the workflow exercising them. Include the selector in the path-filter inputs.
    if: ${{ needs.path-filter.outputs.should_skip != 'true' && github.event_name == 'pull_request' }}
  • Files reviewed: 5/5 changed files
  • Comments generated: 8
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/test_e2e_portal.yml Outdated
Comment thread .github/workflows/test_e2e_portal.yml Outdated
Comment thread e2e/portal/tests/TestingCi/PurposelyFlaky.spec.ts Outdated
Comment thread .github/workflows/test_e2e_portal.yml
Comment thread tools/select-changed-e2e-tests.mjs Outdated
Comment thread e2e/portal/tests/TestingCi/PurposlyStable.spec.ts Outdated
Comment thread tools/select-changed-e2e-tests.mjs Outdated
Comment thread tools/select-changed-e2e-tests.mjs Outdated
@nielsVoogt nielsVoogt changed the title Niels/investigation.flaky test hunter on pr Run find-flaky on CI when new E2E or X% diff Sep 21, 2026
@nielsVoogt
nielsVoogt requested a balanced review from Copilot September 23, 2026 07:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The workflow can report false success, and several selector and validation-fixture issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (8)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Trailing newline skews changed-line percentage

tools/​select-changed-e2e-tests.mjs:105

Most source files end with a newline, and split('\n') then produces a trailing empty element. This makes the denominator one line too large, so a file changed by exactly the configured threshold can be incorrectly excluded (for example, 10 changed lines in a 100-line file is calculated as 10/101). Exclude the terminal split element while preserving genuine blank lines.

Comment thread .github/workflows/test_e2e_portal.yml Outdated
@nielsVoogt nielsVoogt added the chore Something that does not affect the end user label Sep 30, 2026
@nielsVoogt
nielsVoogt force-pushed the niels/investigation.flaky-test-hunter-on-pr branch from cb00552 to 70550aa Compare September 30, 2026 14:06

@elwinschmitz elwinschmitz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets discuss... ;)

Or sit together and do some trial-error-pair-programming on something not-too-complex/big and maintainable/oversee-able...?

Comment on lines +295 to +301
[
path-filter,
lint-code,
detect-flaky-candidates,
test-shard-e2e,
find-flaky-changed-tests,
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[
path-filter,
lint-code,
detect-flaky-candidates,
test-shard-e2e,
find-flaky-changed-tests,
]
- path-filter
- lint-code
- detect-flaky-candidates
- test-shard-e2e
- find-flaky-changed-tests

'Plain' YAML syntax is good enough... the [...]-syntax is just a hack to get it on 1 line...

Comment on lines +19 to +30
import { parseArgs } from 'node:util';

const execFileAsync = ({ command, commandArgs, options = {} }) =>
new Promise((resolve, reject) => {
execFile(command, commandArgs, options, (error, stdout) => {
if (error) {
reject(error);
return;
}
resolve(stdout);
});
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be replaces by:

Suggested change
import { parseArgs } from 'node:util';
const execFileAsync = ({ command, commandArgs, options = {} }) =>
new Promise((resolve, reject) => {
execFile(command, commandArgs, options, (error, stdout) => {
if (error) {
reject(error);
return;
}
resolve(stdout);
});
});
import { parseArgs, promisify } from 'node:util';
const execFileAsync = promisify(execFile);

base: { type: 'string' },
head: { type: 'string', default: 'HEAD' },
threshold: { type: 'string', default: '10' },
'max-files': { type: 'string', default: '15' },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'max-files': { type: 'string', default: '15' },
base: { type: 'string' },
head: {
type: 'string',
default: 'HEAD'
},
threshold: {
type: 'string',
default: '10'
},
'max-files': {
type: 'string',
default: '15'
},

Would be a bit more readable...

run: 'npm run lint'

detect-flaky-candidates:
needs: path-filter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can/should wait on the linting at least to succeed...

Comment on lines +128 to +131
needs:
- path-filter
- lint-code
- detect-flaky-candidates

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
needs:
- path-filter
- lint-code
- detect-flaky-candidates
needs: detect-flaky-candidates

This would only need to mention its 'critical path'-dependencies, I'd think... Not "the whole dependency tree"...

strategy:
fail-fast: false
matrix:
file: ${{ fromJson(needs.detect-flaky-candidates.outputs.files) }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would spawn a runner/job per-changed-spec-file, right?

I wonder how we can 'constrain' this, within some sane limits... 🤔


async function isNewFile({ repositoryRoot, base, path }) {
try {
await execFileAsync({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we don't need to make something-sync-async-and-then-await it?
Why not "just run the command sync"?

return candidates.slice(0, maxFiles);
}

function toE2eRelativePath({ path }) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird capitalization...

Maybe just "toRelativePath"?

return path.slice('e2e/'.length);
}

function writeGithubOutput({ candidates }) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird capitalization, it's "GitHub", so: writeGitHubOutput.

@@ -0,0 +1,187 @@
#!/usr/bin/env node

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be starting to add some linting to this tools-folder...

With adding more and more code, it should all "look alike" and be checked for recommended/best-practice issues etc... (like the MJS-code in the interfaces/portal/scripts-folder..)

And there are probably some more utility-like methods that can be shared around more broadly...

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Something that does not affect the end user

Development

Successfully merging this pull request may close these issues.

3 participants